﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SoundEdge.Dashboard.Project;
using System.Windows.Forms;

namespace SoundEdge.Dashboard
{
    public class Utils
    {
        public static bool SaveProject(SoundEdgeProject project, string fileName = null)
        {
            if (project != null)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.DefaultExt = "seproj";
                dlg.Filter = "Sound Edge project files (*.seproj)|*.seproj";
                dlg.Title = string.Format("Save {0} as", project.Title);
                if (string.IsNullOrWhiteSpace(fileName) && dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    fileName = dlg.FileName;
                }
                if (!string.IsNullOrWhiteSpace(fileName))
                {
                    project.Save(fileName);
                    return true;
                }
            }
            return false;
        }
    }
}
